#ifndef CH_SPLITTERWND_H
#define CH_SPLITTERWND_H

#pragma once

#define CH_SPLIT_DOTTRACKER     0x0001 // Has a dotted tracker
#define CH_SPLIT_NOFULLDRAG     0x0002 // Show pane contents while dragging
#define CH_SPLIT_NOBORDER       0x0004 // Do not draw a border around pane
#define CH_SPLIT_NOSIZE         0x0008 // Do allow sizing

#define CH_SPLIT_SIZECHANGE	  0x1201

#define CX_BORDER   1
#define CY_BORDER   1

class AFX_EXT_CLASS CHSplitterWnd : public CSplitterWnd
{
    DECLARE_DYNAMIC(CHSplitterWnd)

public:

    // Constructs a CHSplitterWnd object.
    //
    CHSplitterWnd();

    // Destroys a CHSplitterWnd object, handles cleanup and de-allocation.
    //
    virtual ~CHSplitterWnd();

protected:

    int		m_nHiddenCol; // Index of the hidden column.
    int		m_nHiddenRow; // Index of the hidden row.
    DWORD	m_dwxStyle;   // The style of the splitter window, see SetSplitterStyle(...).
    BOOL	m_bFullDrag;  // TRUE if full window dragging is enabled.
    CPoint	m_point;      // Previous cursor position.
    BOOL	m_bFlatSplit; // TRUE if the flat splitter style is used.
	int		m_nData;
	CWnd*	m_pOwner;
	virtual CWnd* GetActivePaneEx(int* pRow = NULL, int* pCol = NULL);

public:
	void SetOwner(CWnd* pOwner, int nData);
	CWnd* ReplaceWnd(int nRow, int nCol, CRuntimeClass *pWndClass);
	CWnd* ReplaceWnd(int nRow, int nCol, CWnd* pNewWnd);

    // This member function is called to show the column that was 
    // previously hidden.
    //
    virtual void ShowColumn();
    
    // This member function will hide a column based upon its index.
    //
    virtual void HideColumn(
        // Index of the column to hide.
        int nColHide);

    // This member function is called to show the row that was 
    // previously hidden.
    //
    virtual void ShowRow();
    
    //  This member function will hide a row based upon its index.
    //
    virtual void HideRow(
        // Index of the row to hide.
        int nRowHide);
    
    // This member function is called to switch, or swap a splitter 
    // view with another.
    // Returns TRUE if successful, otherwise FALSE.
    //
    virtual BOOL SwitchView(
        // Specifies a row.
        int nRow,
        // Specifies a column.
        int nCol,
        // Specifies the view to switch the specified pane with.
        CView *pNewView);

    // This member function is called to replace an existing splitter
    // view with another.
    // Returns A CView pointer to the view that was replaced, otherwise NULL.
    //
    virtual CView* ReplaceView(
        //  Specifies a row.
        int nRow,
        //  Specifies a column.
        int nCol,
        //  Specifies the runtime class to replace the specified pane with.
        CRuntimeClass *pViewClass);

    // This member function is called to replace an existing splitter
    // view with another.
    // Returns A CView pointer to the view that was replaced, otherwise NULL.
    //
    virtual CView* ReplaceView(
        //  Specifies a row.
        int nRow,
        //  Specifies a column.
        int nCol,
        // Points to an already existing view.
        CView* pNewView);

    
    //  Call this member function to modify a splitter windows style. Styles to 
    //  be added or removed can be combined by using the bitwise OR (|) 
    //  operator.
    //
    virtual void SetSplitterStyle(
        // Specifies XT_SPLIT_ styles to be added during style modification.  The
        // desired styles for the control bar can be one or more of the following:
        //[pre]
    	// XT_SPLIT_DOTTRACKER - The splitter window will use a dotted
	    //                       tracker rather than the splitter default.
    	// XT_SPLIT_NOFULLDRAG - Disable show window contents while 
	    //                       dragging option even if set in windows.
        //[/pre]
        DWORD dwxStyle);

    // Call this member function to return the current style for the splitter window.
    // Returns The current style of the splitter window. See SetSplitterStyle for more details.
    //
    virtual DWORD GetSplitterStyle();

    // Call this member function to enable / disable flat splitters.
    //
    virtual void EnableFlatLook(
        // TRUE to enable flat splitters.
        BOOL bFlatSplitter);

    //{{AFX_VIRTUAL(CHSplitterWnd)
    protected:
    virtual void OnInvertTracker(const CRect& rect);
    virtual void StartTracking(int ht);
    virtual void StopTracking(BOOL bAccept);
    virtual void DrawTracker(const CRect& rect, CBrush* pBrush);
    virtual void OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg);
    //}}AFX_VIRTUAL

protected:
	BOOL IsChildPaneEx(CWnd *pWnd, int *pRow, int *pCol);
    //{{AFX_MSG(CHSplitterWnd)
    afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg UINT OnNcHitTest(CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

AFX_INLINE DWORD CHSplitterWnd::GetSplitterStyle() {
    return m_dwxStyle;
}

#endif //CH_SPLITTERWND_H
